<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!--    1.引入layui相关的css和js-->
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css"></link>
    <!-- 引入 layui.js -->
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>
    <script src="js/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">名字：</label>
                <div class="layui-input-block">
                    <input name="name" lay-verify="title" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="1" title="男" checked="">
                    <input type="radio" name="sex" value="2" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号：</label>
                <div class="layui-input-block">
                    <input name="phone" lay-verify="title" autocomplete="off" placeholder="留下手机号，省的找不到你" class="layui-input">
                </div>
            </div>

<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">书的编号：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="number" name="bookId" lay-verify="required" lay-reqtext="书籍id" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">书籍编号</label>
                <div class="layui-input-block">
                    <select name="bookId" lay-filter="bianhao">
                        <option value=""></option>
                        <option value="0">1</option>
                        <option value="1" selected="">2</option>
                        <option value="2">3</option>
                        <option value="3">4</option>
                        <option value="4">5</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="demo1">确认借阅</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>

<!--<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>-->
<!--<script src="js/jquery-3.6.0.min.js" charset="utf-8"></script>-->
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form'], function () {
        var form = layui.form
            , layer = layui.layer;
        //监听提交
        form.on('submit(demo1)', function (data) {
            //ajax 调用接口
            $.post("/api/bookborrow/save.do",data.field,function (res) {
                if (res.code == 200){
                    layer.msg("添加成功")
                } else{
                    layer.msg("添加失败")
                }
            });
            return false;
        });
    });
</script>
</body>
</html>